package com.lhq.admin.service.impl;

import com.lhq.admin.dao.UserInfoMapper;
import com.lhq.admin.entity.UserInfo;
import com.lhq.admin.entity.UserInfoExample;
import com.lhq.admin.service.UserInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public List<UserInfo> getUsers(UserInfo userInfo) {
        //1.查询用户列表
        List<UserInfo> userInfos = userInfoMapper.selectByExample(new UserInfoExample());
        //2.....
        return userInfos;
    }

    @Override
    public boolean addUser(UserInfo userInfo) {
        int insert = userInfoMapper.insert(userInfo);
        return insert > 0;
    }

    @Override
    public boolean updateUser(UserInfo userInfo) {
        int i = userInfoMapper.updateByPrimaryKey(userInfo);
        return i > 0;
    }

    @Override
    public boolean deleteUser(int id) {
        return userInfoMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public UserInfo getUserInfo(int id) {
        return userInfoMapper.selectByPrimaryKey(id);
    }
}
